package com.zrrd.controller;

import com.zrrd.entity.Banner;
import com.zrrd.service.BannerService;
import com.zrrd.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Tag(name = "BannerController", description = "轮播图模块接口")
@Controller
@RequestMapping("/api/v1/banner")
public class BannerController {

    @Autowired
    private BannerService bannerService;

    @Operation(summary = "查询全部轮播图", description = "无需token验证")
    @GetMapping("/list")
    @ResponseBody
    public Result list() {
        List<Banner> banners = bannerService.list();
        return banners.get(0).getId() > 0 ? Result.ok(banners) :
                Result.fail(0, "暂无轮播图记录，请联系运维人员");
    }
}
